<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use DB;
class registerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
    
         return view('home.register');   
          }


    public function doRegister(Request $request)
    {
        //dd($request);
    $email = $request->input('email');
    $pass = $request->input('pass');

  	$ob = DB::table('user')->where('email',$email)->first();
     $arr = $request->only('email', 'pass', 'utime');
    
     
       
     if($ob){
     	 return redirect('/register')->with('msg', '用户名已存在');
     }else{
     	$res = DB::table('user')->insert($arr);
          return redirect('/login')->with('msg', '注册成功');
       
            //return back()->with('msg', '注册失败');
          
  	  }
    }
}
    	